package com.xue566.controller;

import com.xue566.config.LogPointer;
import com.xue566.entity.SchoolEntity;
import com.xue566.enums.StateEnum;
import com.xue566.service.ISchoolService;
import com.xue566.util.ResultBody;
import com.xue566.util.StateException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: Wuzh
 * @Description:
 * @Date Created in 21:55 2020/8/16
 * @return
 */
@RestController
@RequestMapping("school")
@Slf4j
public class SchoolController {

    @Resource
    private ISchoolService iSchoolService;

    @LogPointer(value = "学校列表日志")
    @RequestMapping("/queryList")
    public ResultBody schoolList (@RequestBody SchoolEntity schoolEntity) {
        log.info("schoolList: {} - {}", schoolEntity.getTrackId(), schoolEntity);
        return iSchoolService.selectAllSchool(schoolEntity);
    }

    @RequestMapping("/save")
    public ResultBody<SchoolEntity> saveSchool (@RequestBody SchoolEntity schoolEntity) {
        log.info("saveSchool: {} - {}", schoolEntity.getTrackId(), schoolEntity);
        return iSchoolService.saveSchool(schoolEntity);
    }

    @RequestMapping("/selectSchool")
    public ResultBody<SchoolEntity> selectSchool (@RequestBody SchoolEntity schoolEntity) {
        log.info("selectSchool: {} - {}", schoolEntity.getTrackId(), schoolEntity);
        return iSchoolService.selectSchool(schoolEntity);
    }


    @RequestMapping("/updateSchool")
    public ResultBody<SchoolEntity> updateSchool (@RequestBody SchoolEntity schoolEntity) {
        log.info("updateSchool: {} - {}", schoolEntity.getTrackId(), schoolEntity);
        return iSchoolService.updateSchool(schoolEntity);
    }


    @DeleteMapping("/deleteSchool")
    public ResultBody<SchoolEntity> deleteSchool (@RequestBody SchoolEntity schoolEntity) {
        log.info("deleteSchool: {} - {}", schoolEntity.getTrackId(), schoolEntity);
        return iSchoolService.deleteSchool(schoolEntity);
    }

}
